# New ports collection makefile for:	emesene
# Date created:				31 May 2007
# Whom:					Yinghong Liu <relaxbsd@gmail.com>
#
# $FreeBSD: ports/net-im/emesene/Makefile,v 1.14 2010/05/31 02:00:26 ade Exp $
#

PORTNAME=	emesene
PORTVERSION=	1.6.3
CATEGORIES=	net-im python
#MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-${PORTVERSION}
MASTER_SITES=	GOOGLE_CODE

MAINTAINER=	acm@FreeBSD.org
COMMENT=	A MSN Messenger client writen in python

BUILD_DEPENDS=	${PYTHON_SITELIBDIR}/dbus/__init__.py:${PORTSDIR}/devel/py-dbus \
		${PYTHON_SITELIBDIR}/gtk-2.0/pynotify/__init__.py:${PORTSDIR}/devel/py-notify
RUN_DEPENDS:=	${BUILD_DEPENDS}

PROJECTHOST=	bsdistfiles
USE_PYTHON=	yes
USE_GETTEXT=	yes
USE_GNOME=	pygtk2 desktopfileutils
USE_GSTREAMER=	python
INSTALL_ICONS=	yes

PYDISTUTILS_BUILDARGS+=	--prefix=${LOCALBASE}

MAN1=	emesene.1

post-extract:
	@${FIND} ${WRKSRC} -type f -name 'theme~' -exec ${RM} -f \{\} \;
	@cd ${WRKSRC}/ && \
		${RM} -f MANIFEST.in COPYING README && \
		${RM} -Rf docs/ debian/
# Delete 'Spotify.py', because this file needs spotify.exe
	@${RM} -f ${WRKSRC}/plugins_base/currentSong/Spotify.py
# Delete audio players which are not in ports
	@cd ${WRKSRC}/plugins_base/currentSong/ && \
		${RM} -f Consonance.py Foobar2000.py GOMPlayer.py Gmusicbrowser.py \
			Guayadeque.py Listen.py MediaMonkey.py MediaPlayerClassic.py \
			Mesk.py OneByOne.py Songbird.py Winamp.py XMPlay.py

post-patch:
	@${REINPLACE_CMD} -e 's|%%PORTVERSION%%|${PORTVERSION}|' ${WRKSRC}/setup.py
	@${REINPLACE_CMD} -e 's|1.6.X|${PORTVERSION}|' ${WRKSRC}/Controller.py

do-build:
	@cd ${WRKSRC} && \
		${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYSETUP} build_ext -i
	@${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py ${WRKDIR}
	@${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py ${WRKDIR}

	@${ECHO_CMD} "cd ${DATADIR} || exit 1" >> ${WRKDIR}/run.sh
	@${ECHO_CMD} "exec ${PYTHON_CMD} ./${PORTNAME}" >> ${WRKDIR}/run.sh

pre-install:
	@${RM} -fR ${WRKSRC}/libmimic
# Avoid to install libmimic.so in ${PYTHON_SITELIBDIR}
	@${REINPLACE_CMD} -e 's| ext_modules| #ext_modules|' ${WRKSRC}/setup.py

do-install:
	@cd ${WRKSRC} && \
		${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYSETUP} \
		install ${PYDISTUTILS_BUILDARGS}

	@${MKDIR} ${DATADIR}
	@cd ${WRKSRC} && \
		${FIND} . -type d \
		\( ! -regex '.*build.*' -and ! -regex '.*po.*' \
		-and ! -regex '.*misc.*' \) -exec ${MKDIR} "${DATADIR}/{}" \;
.if !defined(NO_LICENSES_INSTALL)
	@cd ${WRKSRC} && \
		${FIND} . -type f \( ! -regex '.*setup\.p.*' \
		-and ! -regex '.*\.orig' \
		-and ! -regex '.*build.*' -and ! -regex '.*po.*' \
		-and ! -regex '.*misc.*' -and ! -regex '.*GPL' -and ! -regex '.*PSF' \) \
		-exec ${INSTALL_DATA} "{}" "${DATADIR}/{}" \;
.else
	@cd ${WRKSRC} && \
		${FIND} . -type f \( ! -regex '.*setup\.p.*' \
		-and ! -regex '.*\.orig' \
		-and ! -regex '.*build.*' -and ! -regex '.*po.*' \
		-and ! -regex '.*misc.*' \) \
		-exec ${INSTALL_DATA} "{}" "${DATADIR}/{}" \;
.endif

	${INSTALL_SCRIPT} ${WRKDIR}/run.sh ${PREFIX}/bin/${PORTNAME}

post-install:
	@-update-desktop-database

.include <bsd.port.mk>
